package com.leetcode.problems009;


import java.util.ArrayList;
import java.util.List;

/**
 * @Description https://leetcode-cn.com/problems/string-to-integer-atoi/
 * @Date 2021/11/20 14:34
 * @Author ghery
 * @Version V1.0
 */
public class Solution2 {



    public boolean isPalindrome(int x) {
        if(x < 0){
            return false;
        }
        if(x < 10){
            return true;
        }
        List<Integer> list = new ArrayList<>();
        while(x != 0){
            int n = x % 10;
            list.add(n);
            x = x /10;
        }
        int l = 0;
        int r = list.size() - 1;
        while(l < r){
            if(list.get(r).intValue() != list.get(l).intValue()){
                return false;
            }
            l++;
            r--;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new Solution2().isPalindrome(1221));
    }
}
